#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

typedef struct time
{
    int h; // 小时
    int m; // 分钟
    int s; // 秒
} TIME;

TIME *addOneHour(TIME *t)
{
    t->h++;
    if (t->h >= 24)
    {
        t->h = 0;
    }

    return t;
}

TIME *addOneMin(TIME *t)
{
    t->m++;
    if (t->m >= 60)
    {
        addOneHour(t);
        t->m -= 60;
    }

    return t;
}

TIME *addOneSec(TIME *t)
{
    t->s++;
    if (t->s >= 60)
    {
        addOneMin(t);
        t->s -= 60;
    }

    return t;
}

int main()
{
    TIME *t = (TIME *)malloc(sizeof(TIME)); // 动态分配内存
    if (t == NULL)
    { // 检查内存是否成功分配
        printf("Memory allocation failed!\n");
        return 1;
    }

    printf("请输入一个时间t的时、分、秒:\n");
    scanf("%d %d %d", &t->h, &t->m, &t->s);

    while (1)
    {
        Sleep(1000);
        printf("%02d:%02d:%02d\n", t->h, t->m, t->s);
        addOneSec(t);
    }

    return 0;
}